package com.hawk.eye.common.config;

import com.hawk.eye.common.encipher.AesSecureProcessor;
import com.hawk.eye.common.encipher.ISecureProcessor;
import com.hawk.eye.common.encipher.MessageEncipher;
import com.hawk.eye.common.utils.JceUtil;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @className: HawkEyeEncipherConfiguration
 * @description:
 * @author: salad
 * @date: 2022/10/9
 **/
@Configuration
@AllArgsConstructor
@EnableConfigurationProperties(HawkEyeEncipherProperties.class)
public class HawkEyeEncipherConfiguration {

    static {
        JceUtil.removeJceSecurity();
    }

    @Bean
    @ConditionalOnMissingBean
    public ISecureProcessor secureProcessor() {
        return new AesSecureProcessor();
    }

    @Bean
    @ConditionalOnMissingBean
    public MessageEncipher messageEncipher(HawkEyeEncipherProperties properties, ISecureProcessor secureProcessor) {
        return new MessageEncipher(properties, secureProcessor);
    }

//    @Bean
//    @ConditionalOnMissingBean
//    public ISecureFactory secureFactory(List<ISecureProcessor> secureProcessorList) {
//        JceUtil.removeJceSecurity();
//        SecureFactory secureFactory = new SecureFactory();
//        secureFactory.add(CryptoType.AES, new AesSecureProcessor());
//        return secureFactory;
//    }


}
